/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.IOException;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.lcdui.game.LayerManager;
import javax.microedition.lcdui.game.Sprite;
import javax.microedition.lcdui.game.TiledLayer;

/**
 *
 * @author Admin
 */
public class GameBackground extends GameCanvas implements Runnable {

    private int move = 0, count = 0;
    int x = 110;
    int y = 270;
    int startframe;
    int speed = 5;
    int speedY = 5;
    private LayerManager mLayerManager;
    private TiledLayer mBackLayer;
    private Sprite mPlayer;
    private int level = 0;

    public GameBackground() {
        super(true);
        setFullScreenMode(true);
        mLayerManager = new LayerManager();
        Graphics g = getGraphics();
        //chon man
        level();

        createPlayer(g);
        createBg1(g);
//        createBg2(g);
//        createBg3(g);
        Thread t = new Thread(this);
        t.start();
    }

// Background man1
    private void createBg1(Graphics g) {
        try {
            Image backgroundImage = Image.createImage("/canh1.png");
            mBackLayer = new TiledLayer(15, 121, backgroundImage, 20, 20);
            int ai[][] = {
                {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 48,
                    53, 49, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 52,
                    60, 59, 53, 49, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 52,
                    60, 61, 60, 54, 47
                }, {
                    47, 47, 48, 53, 49, 47, 47, 47, 47, 52,
                    60, 62, 63, 54, 47
                }, {
                    47, 47, 52, 60, 54, 47, 47, 47, 47, 52,
                    60, 60, 60, 54, 47
                }, {
                    47, 47, 51, 55, 50, 47, 47, 47, 47, 52,
                    60, 60, 60, 54, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 51,
                    55, 55, 55, 50, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    48, 53, 53, 53, 49, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    52, 60, 64, 65, 54, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    52, 60, 61, 66, 54, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    52, 60, 62, 63, 54, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    51, 55, 57, 60, 54, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 51, 55, 50, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    35, 40, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    36, 41, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    37, 42, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    38, 43, 45, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    39, 44, 46, 47, 47
                }, {
                    47, 47, 15, 19, 24, 29, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 16, 20, 25, 30, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 17, 21, 26, 31, 47, 47, 47, 47,
                    1, 4, 8, 47, 47
                }, {
                    47, 47, 18, 22, 27, 32, 47, 47, 47, 47,
                    2, 5, 9, 47, 47
                }, {
                    47, 1, 4, 23, 28, 33, 47, 47, 47, 47,
                    3, 6, 10, 12, 47
                }, {
                    47, 2, 5, 9, 8, 47, 47, 47, 47, 47,
                    47, 7, 11, 13, 47
                }, {
                    47, 3, 6, 10, 12, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 7, 11, 13, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    48, 53, 53, 53, 53
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    52, 60, 60, 61, 60
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    52, 60, 60, 62, 63
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    52, 60, 56, 55, 55
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    51, 55, 50, 47, 47
                }, {
                    35, 40, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    36, 41, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    37, 42, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    38, 43, 45, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    39, 44, 46, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 15, 19, 24, 29,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 16, 20, 25, 30,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 17, 21, 26, 31,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 18, 22, 27, 32,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 23, 28, 33,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 1, 4, 8, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 2, 5, 9, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 3, 6, 10, 12,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 7, 11, 13,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 35, 40, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 36, 41, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 37, 42, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 38, 43, 45, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 39, 44, 46, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    1, 4, 8, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    2, 5, 9, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    3, 6, 10, 12, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 7, 11, 13, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    35, 19, 24, 29, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    36, 20, 25, 30, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    37, 21, 26, 31, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    38, 22, 27, 32, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    39, 23, 28, 33, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 4, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 2, 5, 8, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 3, 6, 10, 12, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 7, 11, 13, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 15, 19, 47, 29
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 16, 20, 25, 30
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 17, 21, 26, 31
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 18, 22, 27, 32
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 23, 28, 33
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 35, 40, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 36, 41, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 37, 42, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 38, 43, 45
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 39, 44, 46
                }, {
                    47, 47, 47, 47, 47, 47, 15, 19, 24, 29,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 16, 20, 25, 30,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 17, 21, 26, 31,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 18, 22, 27, 32,
                    47, 47, 47, 47, 47
                }, {
                    47, 1, 4, 47, 47, 47, 47, 23, 28, 33,
                    47, 47, 47, 47, 47
                }, {
                    47, 2, 5, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 3, 6, 10, 12, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 7, 11, 13, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 8, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }
            };

            for (int i1 = 0; i1 < 121; i1++) {
                for (int j1 = 0; j1 < 15; j1++) {
                    mBackLayer.setCell(j1, i1, ai[i1][j1]);
                }
            }
            mLayerManager.append(mBackLayer);
            mBackLayer.move(0, -2100);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

// Background man2
    private void createBg2(Graphics g) {
        try {
            Image backgroundImage = Image.createImage("/canh1.png");
            mBackLayer = new TiledLayer(15, 161, backgroundImage, 20, 20);
            int ai[][] = {
                {
                    47, 47, 47, 48, 53, 49, 48, 53, 49, 48,
                    53, 49, 47, 47, 47
                }, {
                    47, 47, 48, 58, 61, 59, 58, 61, 59, 58,
                    61, 59, 49, 47, 47
                }, {
                    47, 48, 58, 67, 62, 63, 67, 62, 63, 67,
                    62, 63, 59, 49, 47
                }, {
                    48, 58, 65, 60, 60, 60, 60, 60, 60, 60,
                    60, 60, 60, 59, 49
                }, {
                    58, 61, 66, 60, 64, 65, 60, 64, 65, 60,
                    64, 65, 64, 61, 59
                }, {
                    67, 62, 63, 60, 67, 66, 60, 67, 66, 60,
                    67, 66, 67, 62, 63
                }, {
                    64, 65, 60, 60, 56, 55, 57, 60, 56, 55,
                    57, 60, 60, 64, 65
                }, {
                    61, 66, 60, 56, 50, 47, 52, 60, 54, 47,
                    51, 57, 67, 61, 66
                }, {
                    62, 63, 56, 50, 47, 47, 51, 55, 50, 47,
                    47, 51, 57, 62, 63
                }, {
                    60, 56, 50, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 51, 57, 60
                }, {
                    56, 50, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 51, 57
                }, {
                    50, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 51
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 48, 53,
                    49, 47, 47, 47, 47
                }, {
                    47, 47, 47, 48, 53, 53, 53, 53, 58, 64,
                    59, 53, 53, 53, 53
                }, {
                    47, 47, 48, 58, 61, 60, 64, 61, 60, 67,
                    61, 66, 67, 61, 66
                }, {
                    53, 53, 58, 67, 62, 63, 67, 62, 63, 60,
                    62, 63, 60, 62, 63
                }, {
                    60, 60, 60, 60, 60, 56, 55, 55, 55, 55,
                    55, 55, 55, 55, 55
                }, {
                    55, 55, 55, 55, 55, 50, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 1, 4, 8, 47, 47, 47, 47, 47,
                    47, 35, 40, 47, 47
                }, {
                    47, 47, 2, 5, 9, 47, 15, 19, 24, 29,
                    47, 36, 41, 47, 47
                }, {
                    47, 47, 3, 6, 10, 12, 16, 20, 25, 30,
                    47, 37, 42, 45, 47
                }, {
                    47, 47, 47, 7, 11, 13, 17, 21, 26, 31,
                    47, 38, 43, 45, 47
                }, {
                    47, 47, 47, 47, 47, 47, 18, 22, 27, 32,
                    47, 39, 44, 46, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 23, 28, 33,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 48, 53, 53, 53, 53,
                    53, 53, 53, 53, 53
                }, {
                    53, 53, 53, 53, 53, 58, 64, 65, 64, 61,
                    60, 64, 60, 60, 60
                }, {
                    60, 60, 67, 66, 60, 67, 61, 66, 67, 62,
                    63, 67, 61, 60, 60
                }, {
                    55, 55, 55, 55, 55, 57, 62, 63, 60, 60,
                    60, 60, 62, 63, 60
                }, {
                    47, 47, 47, 47, 47, 51, 55, 55, 55, 55,
                    55, 55, 55, 55, 55
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 48, 53, 53, 49, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 52, 60, 60, 54, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 52, 60, 56, 50, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 51, 55, 50, 47, 47, 48, 53, 49, 47,
                    47, 47, 47, 47, 47
                }, {
                    53, 49, 47, 47, 48, 53, 58, 66, 59, 53,
                    49, 47, 47, 48, 53
                }, {
                    60, 59, 47, 48, 58, 60, 60, 60, 60, 67,
                    59, 49, 48, 58, 60
                }, {
                    60, 60, 54, 52, 65, 64, 65, 60, 64, 65,
                    60, 54, 52, 60, 60
                }, {
                    55, 55, 50, 52, 66, 67, 66, 60, 67, 66,
                    60, 54, 51, 55, 55
                }, {
                    47, 47, 47, 51, 57, 60, 60, 64, 65, 60,
                    56, 50, 47, 47, 47
                }, {
                    47, 47, 47, 47, 51, 55, 55, 55, 55, 55,
                    50, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 48, 53, 49, 47, 47, 47, 48,
                    53, 49, 47, 47, 47
                }, {
                    47, 47, 48, 58, 61, 59, 49, 47, 48, 58,
                    61, 59, 49, 47, 47
                }, {
                    47, 47, 52, 67, 62, 63, 59, 53, 58, 67,
                    62, 63, 54, 47, 47
                }, {
                    47, 47, 52, 60, 60, 60, 60, 60, 60, 60,
                    64, 65, 54, 47, 47
                }, {
                    47, 47, 51, 57, 64, 65, 60, 64, 65, 60,
                    67, 56, 50, 47, 47
                }, {
                    47, 47, 47, 51, 57, 66, 60, 67, 66, 60,
                    56, 50, 47, 47, 47
                }, {
                    47, 47, 47, 47, 51, 57, 60, 60, 60, 56,
                    50, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 51, 57, 60, 56, 50,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 51, 55, 50, 47,
                    47, 47, 47, 47, 47
                }, {
                    53, 49, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    60, 59, 49, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    68, 74, 59, 53, 53, 53, 49, 48, 53, 53,
                    53, 49, 47, 47, 47
                }, {
                    68, 71, 67, 61, 66, 60, 59, 58, 67, 66,
                    64, 54, 47, 47, 47
                }, {
                    70, 71, 60, 62, 63, 60, 67, 66, 60, 60,
                    67, 54, 47, 47, 47
                }, {
                    60, 72, 73, 77, 56, 55, 55, 57, 64, 65,
                    56, 47, 47, 47, 47
                }, {
                    60, 76, 77, 56, 50, 47, 47, 51, 55, 55,
                    50, 47, 47, 47, 47
                }, {
                    64, 65, 56, 50, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    67, 56, 50, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    55, 50, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    53, 53, 53, 53, 53, 53, 49, 47, 48, 53,
                    53, 53, 53, 53, 53
                }, {
                    68, 69, 60, 60, 64, 64, 54, 47, 52, 67,
                    66, 64, 61, 66, 60
                }, {
                    70, 71, 60, 60, 67, 66, 54, 47, 52, 60,
                    60, 67, 62, 63, 60
                }, {
                    67, 66, 64, 65, 60, 60, 54, 47, 52, 65,
                    60, 60, 67, 61, 60
                }, {
                    60, 60, 61, 66, 60, 60, 54, 47, 52, 66,
                    60, 60, 60, 62, 63
                }, {
                    55, 57, 62, 63, 64, 65, 54, 47, 52, 60,
                    64, 65, 60, 56, 55
                }, {
                    47, 51, 55, 55, 55, 55, 50, 47, 51, 55,
                    55, 55, 55, 50, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 48, 53, 53, 53, 53, 53,
                    53, 49, 47, 47, 47
                }, {
                    47, 47, 47, 47, 52, 60, 60, 60, 67, 61,
                    66, 59, 49, 47, 48
                }, {
                    47, 47, 47, 47, 52, 60, 64, 65, 60, 62,
                    63, 64, 59, 53, 58
                }, {
                    47, 47, 47, 47, 52, 60, 67, 66, 60, 60,
                    60, 61, 66, 61, 66
                }, {
                    47, 47, 47, 47, 51, 57, 60, 60, 60, 60,
                    60, 62, 63, 62, 63
                }, {
                    47, 47, 47, 47, 47, 51, 57, 60, 56, 55,
                    55, 55, 55, 55, 55
                }, {
                    47, 47, 47, 47, 47, 47, 51, 55, 50, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    48, 53, 53, 53, 53, 49, 29, 29, 29, 48,
                    53, 53, 53, 53, 49
                }, {
                    58, 60, 60, 60, 60, 59, 53, 53, 53, 58,
                    60, 60, 60, 60, 59
                }, {
                    60, 64, 64, 65, 64, 64, 65, 61, 66, 64,
                    65, 64, 64, 65, 60
                }, {
                    60, 64, 61, 66, 67, 61, 66, 62, 63, 61,
                    66, 67, 61, 66, 60
                }, {
                    60, 67, 62, 63, 60, 62, 63, 60, 60, 62,
                    63, 60, 62, 63, 60
                }, {
                    60, 60, 60, 60, 60, 60, 60, 64, 65, 60,
                    60, 60, 60, 64, 65
                }, {
                    60, 60, 61, 60, 60, 61, 60, 67, 66, 61,
                    60, 60, 61, 67, 66
                }, {
                    60, 60, 62, 63, 60, 62, 63, 60, 60, 62,
                    63, 60, 62, 63, 60
                }, {
                    64, 65, 60, 60, 60, 60, 60, 60, 60, 60,
                    60, 60, 60, 60, 60
                }, {
                    67, 66, 61, 60, 60, 61, 60, 60, 60, 61,
                    60, 60, 61, 60, 60
                }, {
                    60, 60, 62, 63, 60, 62, 63, 60, 60, 62,
                    63, 60, 62, 63, 60
                }, {
                    60, 64, 64, 65, 60, 60, 60, 64, 65, 60,
                    60, 64, 64, 65, 60
                }, {
                    60, 64, 61, 66, 60, 61, 60, 67, 66, 61,
                    60, 67, 61, 66, 60
                }, {
                    60, 64, 62, 63, 60, 62, 63, 60, 60, 62,
                    63, 60, 62, 63, 60
                }, {
                    57, 67, 66, 60, 60, 60, 60, 61, 60, 60,
                    60, 60, 60, 60, 56
                }, {
                    51, 55, 55, 55, 55, 57, 60, 60, 60, 56,
                    55, 55, 55, 55, 50
                }, {
                    47, 47, 47, 47, 47, 51, 55, 55, 55, 50,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 48, 53, 53, 53, 53, 49, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 48, 58, 60, 60, 64, 65, 59, 53, 53,
                    53, 49, 47, 47, 47
                }, {
                    48, 58, 68, 69, 60, 67, 66, 60, 60, 67,
                    66, 54, 47, 47, 47
                }, {
                    58, 61, 70, 71, 60, 60, 60, 64, 65, 60,
                    60, 54, 47, 47, 47
                }, {
                    67, 62, 63, 72, 73, 60, 60, 67, 66, 56,
                    55, 50, 47, 47, 47
                }, {
                    55, 55, 55, 55, 55, 55, 55, 55, 55, 50,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 48, 53, 53, 53, 53, 53, 53,
                    53, 49, 47, 47, 47
                }, {
                    47, 47, 48, 58, 60, 60, 64, 61, 65, 60,
                    60, 59, 49, 47, 47
                }, {
                    47, 48, 58, 64, 65, 60, 67, 62, 63, 60,
                    60, 60, 59, 49, 47
                }, {
                    48, 58, 64, 61, 66, 60, 60, 64, 65, 60,
                    60, 61, 60, 59, 49
                }, {
                    51, 57, 67, 62, 63, 60, 60, 67, 66, 60,
                    60, 62, 63, 56, 50
                }, {
                    47, 51, 57, 60, 60, 60, 60, 61, 60, 60,
                    60, 60, 56, 50, 47
                }, {
                    47, 47, 51, 57, 60, 60, 56, 55, 57, 60,
                    60, 56, 50, 47, 47
                }, {
                    47, 47, 47, 51, 55, 55, 50, 29, 51, 55,
                    55, 50, 29, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 48, 53, 53, 53, 53,
                    53, 53, 53, 53, 53
                }, {
                    47, 47, 47, 47, 48, 58, 60, 60, 60, 60,
                    60, 72, 73, 74, 75
                }, {
                    47, 47, 47, 47, 52, 65, 60, 60, 64, 65,
                    60, 75, 76, 77, 56
                }, {
                    47, 47, 47, 47, 52, 66, 60, 60, 61, 66,
                    64, 65, 60, 56, 50
                }, {
                    47, 47, 47, 47, 51, 55, 57, 60, 62, 63,
                    67, 66, 56, 50, 29
                }, {
                    47, 47, 47, 47, 47, 47, 51, 55, 55, 55,
                    55, 55, 50, 29, 29
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 48, 53, 53, 53,
                    49, 47, 47, 47, 47
                }, {
                    49, 47, 48, 53, 53, 53, 58, 67, 61, 66,
                    59, 53, 53, 53, 53
                }, {
                    59, 53, 58, 61, 66, 60, 60, 60, 62, 63,
                    60, 60, 67, 61, 66
                }, {
                    61, 66, 60, 62, 63, 60, 64, 65, 60, 64,
                    64, 65, 60, 62, 63
                }, {
                    62, 63, 60, 68, 69, 60, 67, 66, 60, 67,
                    61, 66, 60, 60, 60
                }, {
                    60, 60, 60, 70, 71, 60, 60, 60, 60, 60,
                    62, 63, 60, 56, 55
                }, {
                    55, 55, 55, 57, 66, 60, 56, 55, 55, 55,
                    55, 55, 55, 50, 47
                }, {
                    47, 47, 47, 51, 55, 55, 50, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    53, 49, 47, 47, 47, 48, 53, 53, 53, 53,
                    49, 47, 48, 53, 53
                }, {
                    60, 59, 53, 53, 53, 58, 60, 60, 60, 60,
                    54, 47, 52, 64, 65
                }, {
                    64, 65, 60, 64, 64, 65, 60, 64, 65, 60,
                    54, 47, 52, 61, 66
                }, {
                    67, 66, 60, 67, 61, 66, 60, 67, 66, 60,
                    54, 47, 52, 62, 63
                }, {
                    60, 60, 60, 60, 62, 63, 60, 60, 60, 56,
                    50, 47, 51, 55, 55
                }, {
                    56, 55, 55, 55, 57, 78, 56, 55, 55, 50,
                    47, 47, 47, 47, 47
                }, {
                    50, 47, 47, 47, 51, 79, 50, 47, 47, 47,
                    47, 47, 47, 47, 47
                }, {
                    53, 49, 47, 47, 47, 80, 47, 48, 53, 53,
                    53, 49, 47, 47, 48
                }, {
                    60, 59, 53, 53, 53, 53, 53, 58, 60, 60,
                    60, 59, 53, 53, 58
                }, {
                    60, 64, 65, 60, 60, 60, 60, 64, 60, 64,
                    61, 60, 60, 60, 60
                }, {
                    60, 61, 66, 64, 65, 60, 60, 68, 69, 67,
                    62, 63, 60, 64, 65
                }, {
                    60, 62, 63, 61, 66, 60, 60, 70, 71, 60,
                    60, 60, 60, 67, 66
                }, {
                    60, 60, 60, 62, 63, 60, 60, 67, 72, 73,
                    74, 64, 61, 60, 60
                }, {
                    60, 61, 60, 64, 65, 60, 61, 60, 75, 76,
                    77, 67, 62, 63, 60
                }, {
                    60, 62, 63, 67, 66, 60, 62, 63, 60, 67,
                    66, 60, 60, 60, 60
                }, {
                    60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
                    60, 60, 60, 64, 65
                }, {
                    60, 64, 61, 60, 60, 64, 61, 60, 64, 65,
                    61, 60, 61, 67, 66
                }, {
                    61, 67, 62, 63, 61, 67, 62, 63, 61, 66,
                    62, 63, 62, 63, 60
                }, {
                    62, 63, 60, 67, 62, 63, 60, 60, 62, 63,
                    60, 60, 60, 60, 60
                }, {
                    55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
                    55, 55, 55, 55, 55
                }
            };

            for (int i1 = 0; i1 < 161; i1++) {
                for (int j1 = 0; j1 < 15; j1++) {
                    mBackLayer.setCell(j1, i1, ai[i1][j1]);
                }
            }
            mLayerManager.append(mBackLayer);
            mBackLayer.move(0, -2900);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

// Background man3
    private void createBg3(Graphics g) {
        try {
            Image backgroundImage = Image.createImage("/canh3.png");
            mBackLayer = new TiledLayer(15, 201, backgroundImage, 20, 20);
            int ai[][] = {
                {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    33, 33, 1, 1, 33, 33, 1, 1, 1, 33,
                    33, 1, 1, 33, 33
                }, {
                    33, 33, 1, 1, 33, 33, 1, 1, 1, 33,
                    33, 1, 1, 33, 33
                }, {
                    33, 33, 1, 1, 33, 33, 1, 1, 1, 33,
                    33, 1, 1, 33, 33
                }, {
                    33, 33, 1, 1, 33, 33, 1, 1, 1, 33,
                    33, 1, 1, 33, 33
                }, {
                    64, 64, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 64, 64
                }, {
                    64, 64, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 64, 64
                }, {
                    64, 67, 64, 64, 64, 64, 35, 35, 35, 64,
                    64, 64, 67, 64, 64
                }, {
                    64, 64, 64, 64, 64, 64, 35, 35, 35, 64,
                    67, 64, 64, 64, 64
                }, {
                    67, 64, 64, 67, 64, 64, 35, 35, 35, 64,
                    64, 64, 67, 64, 64
                }, {
                    64, 64, 64, 64, 64, 64, 35, 35, 35, 64,
                    64, 67, 64, 64, 64
                }, {
                    64, 67, 64, 64, 64, 64, 35, 35, 35, 64,
                    64, 64, 64, 64, 64
                }, {
                    64, 64, 64, 64, 64, 67, 35, 35, 35, 64,
                    67, 64, 67, 64, 67
                }, {
                    64, 64, 64, 64, 64, 64, 35, 35, 35, 64,
                    64, 64, 64, 64, 64
                }, {
                    67, 64, 64, 67, 64, 64, 35, 35, 35, 64,
                    64, 64, 64, 64, 64
                }, {
                    64, 64, 64, 64, 64, 1, 35, 35, 35, 1,
                    64, 64, 67, 64, 64
                }, {
                    34, 34, 34, 34, 34, 34, 1, 1, 1, 34,
                    34, 34, 34, 34, 34
                }, {
                    34, 34, 34, 34, 34, 34, 1, 1, 1, 34,
                    34, 34, 34, 34, 34
                }, {
                    34, 34, 34, 34, 34, 34, 1, 1, 1, 34,
                    34, 34, 34, 34, 34
                }, {
                    64, 64, 64, 64, 64, 1, 35, 35, 35, 1,
                    64, 64, 64, 64, 64
                }, {
                    64, 67, 67, 67, 64, 64, 35, 35, 35, 64,
                    64, 67, 64, 64, 67
                }, {
                    64, 67, 64, 67, 67, 64, 35, 35, 35, 64,
                    64, 67, 64, 64, 64
                }, {
                    64, 64, 64, 64, 64, 64, 35, 35, 35, 64,
                    64, 67, 64, 64, 67
                }, {
                    64, 67, 64, 64, 64, 64, 35, 35, 35, 64,
                    64, 64, 67, 64, 64
                }, {
                    64, 64, 67, 67, 67, 64, 35, 35, 35, 64,
                    67, 64, 64, 64, 64
                }, {
                    67, 67, 64, 64, 64, 64, 35, 35, 35, 64,
                    67, 64, 64, 64, 64
                }, {
                    69, 64, 67, 64, 64, 64, 35, 35, 35, 64,
                    67, 67, 67, 64, 64
                }, {
                    70, 64, 64, 64, 64, 64, 35, 35, 35, 64,
                    64, 64, 64, 67, 64
                }, {
                    64, 64, 64, 67, 64, 64, 35, 35, 35, 64,
                    64, 64, 64, 64, 64
                }, {
                    64, 64, 64, 64, 65, 64, 35, 35, 35, 64,
                    64, 67, 64, 64, 64
                }, {
                    64, 67, 64, 64, 66, 64, 35, 35, 35, 64,
                    64, 64, 64, 64, 64
                }, {
                    64, 64, 64, 64, 64, 64, 35, 35, 35, 64,
                    67, 64, 67, 64, 64
                }, {
                    64, 68, 69, 64, 64, 64, 35, 35, 35, 64,
                    67, 64, 64, 64, 64
                }, {
                    64, 71, 70, 64, 67, 64, 35, 35, 35, 64,
                    64, 64, 64, 67, 64
                }, {
                    64, 64, 64, 64, 64, 64, 35, 35, 35, 64,
                    67, 67, 64, 64, 64
                }, {
                    28, 28, 28, 28, 28, 28, 35, 35, 35, 28,
                    28, 28, 28, 28, 28
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                    1, 1, 1, 1, 1
                }, {
                    47, 50, 49, 37, 37, 47, 50, 50, 50, 49,
                    37, 37, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 50, 48, 48, 50, 50, 50, 50, 50,
                    48, 48, 50, 50, 49
                }, {
                    47, 50, 50, 50, 50, 50, 50, 50, 50, 50,
                    50, 50, 50, 50, 49
                }, {
                    47, 50, 50, 46, 46, 50, 50, 50, 50, 50,
                    46, 46, 50, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 50, 48, 48, 50, 50, 50, 50, 50,
                    48, 48, 50, 50, 49
                }, {
                    47, 50, 50, 50, 50, 50, 50, 50, 50, 50,
                    50, 50, 50, 50, 49
                }, {
                    47, 50, 50, 50, 50, 50, 50, 50, 50, 50,
                    50, 50, 50, 50, 49
                }, {
                    47, 50, 50, 46, 46, 50, 50, 50, 50, 50,
                    46, 46, 50, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 50, 48, 48, 50, 50, 50, 50, 50,
                    48, 48, 50, 50, 49
                }, {
                    47, 50, 50, 50, 50, 50, 50, 50, 50, 50,
                    50, 50, 50, 50, 49
                }, {
                    47, 50, 50, 50, 50, 50, 50, 50, 50, 50,
                    50, 50, 50, 50, 49
                }, {
                    47, 50, 50, 46, 46, 50, 50, 50, 50, 50,
                    46, 46, 50, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 51, 51, 47, 50, 50, 50, 49,
                    51, 51, 47, 50, 49
                }, {
                    47, 50, 49, 39, 39, 47, 50, 50, 50, 49,
                    39, 39, 47, 50, 49
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 1,
                    1, 1, 1, 1, 1
                }, {
                    39, 39, 39, 39, 39, 41, 35, 35, 35, 44,
                    39, 39, 39, 39, 39
                }, {
                    27, 27, 27, 27, 27, 36, 35, 35, 35, 38,
                    28, 28, 28, 28, 28
                }, {
                    27, 27, 27, 27, 27, 36, 35, 35, 35, 38,
                    28, 27, 27, 27, 29
                }, {
                    27, 27, 27, 27, 27, 36, 35, 35, 35, 38,
                    28, 27, 27, 27, 29
                }, {
                    27, 27, 27, 27, 27, 36, 35, 35, 35, 38,
                    28, 27, 27, 27, 29
                }, {
                    27, 27, 27, 27, 27, 36, 35, 35, 35, 38,
                    28, 27, 27, 27, 29
                }, {
                    27, 27, 27, 27, 27, 36, 35, 35, 35, 38,
                    28, 27, 27, 28, 28
                }, {
                    27, 27, 27, 27, 27, 36, 35, 35, 35, 43,
                    33, 27, 27, 33, 28
                }, {
                    27, 27, 27, 27, 27, 36, 35, 35, 35, 1,
                    1, 1, 1, 1, 1
                }, {
                    27, 27, 27, 27, 27, 36, 35, 35, 35, 44,
                    33, 33, 39, 41, 1
                }, {
                    27, 27, 27, 27, 27, 36, 35, 35, 35, 38,
                    15, 16, 31, 36, 1
                }, {
                    33, 33, 33, 33, 33, 36, 35, 35, 35, 38,
                    19, 20, 32, 36, 1
                }, {
                    33, 33, 33, 33, 33, 36, 35, 35, 35, 38,
                    19, 20, 31, 36, 1
                }, {
                    1, 15, 16, 1, 1, 36, 35, 35, 35, 38,
                    19, 20, 32, 36, 1
                }, {
                    1, 17, 18, 1, 1, 36, 35, 35, 35, 38,
                    19, 20, 31, 36, 1
                }, {
                    1, 19, 20, 1, 33, 36, 35, 35, 35, 38,
                    21, 22, 32, 36, 1
                }, {
                    1, 19, 20, 1, 33, 36, 35, 35, 35, 1,
                    1, 1, 1, 36, 1
                }, {
                    1, 21, 22, 1, 33, 36, 35, 35, 35, 38,
                    28, 28, 28, 36, 1
                }, {
                    1, 1, 1, 1, 1, 36, 35, 35, 35, 38,
                    28, 28, 28, 36, 1
                }, {
                    1, 1, 1, 1, 1, 36, 35, 35, 35, 38,
                    2, 3, 1, 36, 1
                }, {
                    1, 1, 1, 1, 33, 36, 35, 35, 35, 38,
                    4, 5, 1, 36, 1
                }, {
                    37, 33, 1, 1, 33, 42, 35, 35, 35, 43,
                    1, 1, 37, 42, 1
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 1,
                    1, 1, 1, 1, 1
                }, {
                    39, 39, 39, 39, 39, 41, 35, 35, 35, 44,
                    39, 1, 1, 39, 39
                }, {
                    33, 33, 33, 33, 33, 36, 35, 35, 35, 38,
                    33, 1, 1, 33, 1
                }, {
                    1, 1, 1, 1, 1, 36, 35, 35, 35, 38,
                    1, 15, 16, 1, 1
                }, {
                    1, 6, 7, 8, 1, 36, 35, 35, 35, 38,
                    33, 17, 18, 1, 33
                }, {
                    1, 9, 10, 11, 1, 36, 35, 35, 35, 38,
                    1, 19, 20, 1, 1
                }, {
                    33, 12, 13, 14, 1, 36, 35, 35, 35, 38,
                    33, 21, 22, 33, 1
                }, {
                    37, 37, 37, 37, 37, 42, 35, 35, 35, 43,
                    37, 1, 1, 37, 37
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 1,
                    1, 1, 1, 1, 1
                }, {
                    39, 39, 39, 39, 39, 39, 35, 35, 35, 39,
                    39, 39, 39, 39, 39
                }, {
                    37, 37, 37, 37, 37, 37, 47, 50, 49, 37,
                    37, 37, 37, 37, 37
                }, {
                    45, 45, 45, 45, 45, 45, 47, 50, 49, 45,
                    45, 45, 45, 45, 45
                }, {
                    45, 45, 45, 45, 45, 45, 47, 50, 49, 45,
                    45, 45, 45, 45, 45
                }, {
                    39, 39, 39, 39, 39, 41, 47, 50, 49, 44,
                    39, 39, 39, 39, 39
                }, {
                    37, 37, 37, 37, 37, 42, 35, 35, 35, 38,
                    28, 28, 28, 28, 28
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 38,
                    28, 30, 27, 27, 29
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 38,
                    1, 27, 27, 27, 31
                }, {
                    39, 39, 39, 39, 39, 41, 35, 35, 35, 38,
                    28, 27, 27, 27, 31
                }, {
                    31, 31, 31, 31, 31, 36, 35, 35, 35, 38,
                    28, 30, 27, 27, 29
                }, {
                    45, 45, 30, 27, 31, 36, 35, 35, 35, 38,
                    28, 32, 27, 27, 28
                }, {
                    45, 45, 30, 27, 31, 36, 35, 35, 35, 38,
                    28, 32, 27, 27, 28
                }, {
                    6, 7, 8, 27, 31, 36, 35, 35, 35, 38,
                    28, 30, 27, 27, 29
                }, {
                    9, 10, 11, 27, 31, 36, 35, 35, 35, 38,
                    28, 27, 27, 27, 27
                }, {
                    12, 13, 14, 27, 31, 36, 35, 35, 35, 38,
                    28, 27, 27, 27, 27
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 38,
                    28, 27, 27, 27, 27
                }, {
                    31, 31, 31, 31, 31, 36, 35, 35, 35, 38,
                    28, 28, 1, 28, 28
                }, {
                    37, 37, 37, 37, 37, 37, 35, 35, 35, 43,
                    37, 37, 1, 37, 37
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 44,
                    39, 39, 39, 39, 39
                }, {
                    39, 39, 39, 39, 39, 41, 35, 35, 35, 38,
                    33, 1, 33, 1, 33
                }, {
                    28, 28, 28, 28, 28, 36, 35, 35, 35, 38,
                    1, 1, 1, 1, 1
                }, {
                    29, 45, 45, 30, 28, 36, 35, 35, 35, 38,
                    1, 1, 1, 1, 1
                }, {
                    27, 2, 3, 27, 28, 36, 35, 35, 35, 38,
                    1, 1, 1, 1, 1
                }, {
                    27, 4, 5, 27, 28, 36, 35, 35, 35, 38,
                    1, 1, 1, 1, 1
                }, {
                    28, 1, 28, 28, 28, 36, 35, 35, 35, 38,
                    33, 1, 1, 1, 33
                }, {
                    37, 1, 37, 37, 37, 42, 35, 35, 35, 43,
                    37, 37, 1, 37, 37
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 1,
                    1, 1, 1, 1, 1
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 1,
                    1, 1, 1, 1, 1
                }, {
                    39, 39, 39, 39, 39, 41, 35, 35, 35, 44,
                    39, 39, 39, 39, 39
                }, {
                    28, 29, 27, 27, 28, 36, 35, 35, 35, 38,
                    28, 28, 28, 28, 28
                }, {
                    28, 29, 27, 27, 28, 36, 35, 35, 35, 38,
                    28, 29, 45, 45, 30
                }, {
                    28, 27, 27, 27, 28, 36, 35, 35, 35, 38,
                    28, 29, 45, 45, 30
                }, {
                    28, 27, 27, 27, 27, 36, 35, 35, 35, 38,
                    28, 6, 7, 8, 27
                }, {
                    32, 32, 32, 32, 32, 36, 35, 35, 35, 38,
                    28, 9, 10, 11, 27
                }, {
                    32, 23, 24, 1, 32, 36, 35, 35, 35, 38,
                    28, 12, 13, 14, 27
                }, {
                    31, 25, 26, 1, 32, 36, 35, 35, 35, 38,
                    28, 28, 1, 28, 28
                }, {
                    31, 1, 1, 1, 1, 1, 35, 35, 35, 43,
                    37, 37, 1, 37, 37
                }, {
                    31, 31, 31, 31, 31, 36, 35, 35, 35, 1,
                    1, 1, 1, 1, 1
                }, {
                    40, 40, 40, 40, 40, 36, 35, 35, 35, 1,
                    1, 1, 1, 1, 1
                }, {
                    40, 40, 40, 40, 40, 36, 35, 35, 35, 44,
                    39, 39, 39, 39, 39
                }, {
                    33, 1, 33, 1, 33, 36, 35, 35, 35, 38,
                    28, 28, 28, 28, 28
                }, {
                    6, 7, 8, 1, 1, 36, 35, 35, 35, 38,
                    28, 28, 28, 28, 28
                }, {
                    9, 10, 11, 1, 1, 36, 35, 35, 35, 38,
                    28, 27, 27, 27, 27
                }, {
                    12, 13, 14, 1, 33, 36, 35, 35, 35, 38,
                    28, 29, 27, 27, 30
                }, {
                    37, 1, 37, 37, 37, 42, 35, 35, 35, 38,
                    28, 29, 27, 27, 30
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 38,
                    28, 27, 27, 27, 27
                }, {
                    1, 1, 1, 1, 1, 1, 35, 35, 35, 38,
                    27, 27, 27, 27, 27
                }, {
                    44, 39, 39, 39, 39, 41, 35, 35, 35, 38,
                    28, 28, 28, 28, 28
                }, {
                    28, 28, 28, 28, 28, 36, 35, 35, 35, 38,
                    32, 31, 32, 31, 31
                }, {
                    45, 45, 23, 24, 28, 36, 35, 35, 35, 38,
                    31, 2, 3, 45, 32
                }, {
                    45, 45, 25, 26, 28, 36, 35, 35, 35, 38,
                    32, 4, 5, 45, 32
                }, {
                    28, 28, 27, 28, 28, 36, 35, 35, 35, 38,
                    31, 1, 31, 31, 31
                }, {
                    43, 37, 1, 37, 37, 42, 1, 1, 1, 43,
                    37, 1, 37, 37, 37
                }, {
                    34, 34, 34, 34, 34, 34, 1, 1, 1, 34,
                    34, 34, 34, 34, 34
                }, {
                    34, 34, 34, 34, 34, 34, 1, 1, 1, 34,
                    34, 34, 34, 34, 34
                }, {
                    37, 37, 35, 37, 37, 37, 37, 35, 37, 37,
                    37, 37, 35, 37, 37
                }, {
                    69, 64, 35, 64, 67, 64, 64, 35, 64, 64,
                    64, 64, 35, 64, 64
                }, {
                    70, 64, 35, 68, 69, 64, 64, 35, 64, 64,
                    64, 64, 35, 68, 69
                }, {
                    64, 65, 35, 71, 70, 64, 67, 35, 64, 64,
                    64, 64, 35, 71, 70
                }, {
                    64, 66, 35, 64, 64, 64, 64, 35, 64, 68,
                    69, 64, 35, 64, 68
                }, {
                    64, 60, 73, 61, 64, 67, 60, 73, 61, 71,
                    70, 60, 73, 61, 71
                }, {
                    59, 54, 74, 55, 59, 59, 54, 74, 55, 59,
                    59, 54, 74, 55, 59
                }, {
                    51, 51, 74, 51, 51, 51, 51, 74, 51, 51,
                    51, 51, 74, 51, 51
                }, {
                    51, 51, 74, 51, 51, 51, 51, 74, 51, 51,
                    51, 51, 74, 51, 51
                }, {
                    51, 52, 79, 53, 51, 51, 52, 79, 53, 51,
                    51, 52, 79, 53, 51
                }, {
                    57, 62, 78, 63, 57, 57, 62, 78, 63, 57,
                    57, 62, 78, 63, 57
                }, {
                    71, 70, 64, 64, 64, 64, 64, 64, 64, 64,
                    71, 70, 64, 64, 64
                }, {
                    64, 64, 64, 68, 69, 64, 64, 64, 64, 65,
                    64, 64, 64, 68, 69
                }, {
                    64, 64, 64, 71, 70, 64, 64, 64, 64, 66,
                    64, 64, 64, 71, 70
                }, {
                    59, 59, 61, 64, 64, 64, 60, 59, 59, 59,
                    59, 59, 61, 64, 64
                }, {
                    51, 51, 55, 59, 59, 59, 54, 51, 51, 51,
                    51, 51, 55, 59, 59
                }
            };

            for (int i1 = 0; i1 < 201; i1++) {
                for (int j1 = 0; j1 < 15; j1++) {
                    mBackLayer.setCell(j1, i1, ai[i1][j1]);
                }
            }
            mLayerManager.append(mBackLayer);
            mBackLayer.move(0, -3700);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public void run() {
        while (true) {
            if (count < 2100) {
                try {
                    int ks = getKeyStates();
                    int x1 = x;
                    int y1 = y;

                    if ((ks & RIGHT_PRESSED) != 0) {
                        speed = 5;
                        if (x > getWidth() - 26) {
                            speed = 0;
                        }
                        startframe = 1;
                        x = x + speed;
                    }
                    if (ks == 0) {
                        startframe = 0;
                    }
                    if ((ks & LEFT_PRESSED) != 0) {
                        speed = 5;
                        if (x < 1) {
                            speed = 0;
                        }
                        startframe = -1;
                        x = x - speed;
                    }  if ((ks & UP_PRESSED) != 0) {
                        speedY = 5;
                        if (y < 1) {
                            speedY = 0;
                        }
                        startframe = 1;
                        y = y - speedY;
                    } else if ((ks & DOWN_PRESSED) != 0) {
                        speedY = 5;
                        if (y > getHeight() - 26) {
                            speedY = 0;
                        }
                        startframe = 1;
                        y = y + speedY;
                    }
                    mPlayer.setPosition(x, y);
                    mPlayer.setFrame(startframe + 1);
                    Graphics g = getGraphics();
                    g.setColor(255, 255, 255);
                    g.fillRect(0, 0, getWidth(), getHeight());
                    move = 1;
                    mBackLayer.move(0, move);
                    count = count + 1;
                    mLayerManager.paint(g, 0, 0);
                    flushGraphics();
                    Thread.currentThread().sleep(50);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
    }

    private void level() {
//        if (level=1){
//            mBackLayer=1;
//            count = 2100;
//        } if (level=2) {
//            mBackLayer=2;
//            count = 2900;
//        } if (level=3) {
//            mBackLayer=3;
//            count = 3700;
//        }
    }

    private void createPlayer(Graphics g) {
        try {
            Image mImage = Image.createImage("/nguoichoi.png");
            mPlayer = new Sprite(mImage, 25, 25);
            mPlayer.setPosition(x, y);
            mPlayer.setFrame(1);
            mPlayer.defineReferencePixel(12, 12);
            mLayerManager.append(mPlayer);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
